import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UsersEntity } from './Entity/user.entity';
import { OrderModule } from './modules/order.module';
import { RoleEntity } from './Entity/role.entity';
import { MenuEntity } from './Entity/menu.entity';
import { OrderEntity } from './Entity/order.entity';
import { ChannelEntity } from './Entity/channel.entity';
import { RoomEntity } from './Entity/room.entity';
import { OrderRoomEntity } from './Entity/order_room.entity';
import { RoomTypeEntity } from './Entity/roomType.entity';
import { OrderPaymentEntity } from './Entity/order_payment.entity';
import { GuestEntity } from './Entity/guest.entity';
import { OrderGuestEntity } from './Entity/order_guest.entity';
import { LogEntity } from './Entity/log.entity';
import { ActionMoudle } from './modules/action/modules/action.module';
import { AuthModule } from './modules/auth/auth.module';
import { RoleMoudle } from './modules/role.moudle';
import { MenuModule } from './modules/menu.module';
import { UsersModule } from './modules/users.module';
import { LoggerMiddleware } from './common/middleware/looger.middleware';
import { MessageEntity } from './Entity/message.entity';
import { MessageModule } from './modules/message.module';
import { WebSocketModule } from './modules/websocket.module';
import { DataEntity } from './Entity/data.entity';


@Module({
    imports: [
        ActionMoudle,
        AuthModule,
        RoleMoudle,
        MenuModule,
        UsersModule,
        OrderModule,
        MessageModule,
        WebSocketModule,
        TypeOrmModule.forRoot({
            type: 'mysql',
            host: '127.0.0.1',
            port: 3306,
            username: 'root',
            password: 'wjjabc1534.',
            database: 'nest',
            timezone: 'UTC',
            entities: [
                UsersEntity,
                RoleEntity,
                MenuEntity,
                OrderEntity,
                ChannelEntity,
                RoomEntity,
                RoomTypeEntity,
                OrderRoomEntity,
                OrderPaymentEntity,
                GuestEntity,
                OrderGuestEntity,
                LogEntity,
                MessageEntity,
                DataEntity
            ],
            synchronize: true,
            // logger: "advanced-console",
            // logging: true,
        })],

})
export class AppModule {
    configure(consumer: MiddlewareConsumer) {
        consumer
            .apply(LoggerMiddleware)
            .exclude({ path: 'hello', method: RequestMethod.POST })
            .forRoutes('hello');
    }
}
